#ifndef INCLUDE_SNMPFUNC_H
#define INCLUDE_SNMPFUNC_H
#include "snmptype.h"
#include "a_localio.h"
_INT8 snmpd_init(void);
void snmp_data_init(_UINT32 sock,_UINT8 *outbuf,_UINT16 maxLen);
void trapSvrMac_learn_timer_init(void);
void Send_SNMP_Packet(SNMP_PKT_T *);
void set_config_change(_UINT8 bChange);
void snmpAgentOutput(SNMP_PKT_T * , _UINT16);
_INT16 SNMP_Community_Validate(SNMP_PKT_T *rp);
_INT16 SNMP_Decode_Packet_WER(_UINT8 *,_UINT16 ,SNMP_PKT_T *);
void SNMP_Process_Rcvd_Packet(_UINT8 *,_UINT16 ,_UINT32 ,_UINT16 ,_INT8);
_INT16 SNMP_Encode_Finish(SNMP_PKT_T * ,_UINT8 *,_UINT16);
_UINT16 Get_Vb_Size(VB_T *);
_UINT16 Set_Vbl_Sizes(SNMP_PKT_T *);
_UINT16 Set_Pdu_Size(SNMP_PKT_T *);
_UINT16 Bufsize_For_Normal_Pkt(SNMP_PKT_T *);
SNMP_PKT_T *SNMP_Create_Trap(SNMP_PKT_T *rp,OBJ_ID_T *trapOid,_UINT32 specfic);
_UINT16 Bufsize_For_Trap_pkt(SNMP_PKT_T *);
_UINT16 SNMP_Bufsize_For_Packet(SNMP_PKT_T *);
_UINT16 A_SizeOfObjectId(OBJ_ID_T *);
_UINT16 A_SizeOfInt(_INT32);
_UINT32 get_sysuptime(void);
_UINT32 get_local_ip(void);
void A_EncodeStart(void);
_UINT16 A_SizeOfUnsignedInt(_UINT32);
_UINT16 A_EncodeHelper(_UINT8 *ebp, _UINT8 *bp, _UINT16 leng);
void A_EncodeSubId(_UINT32 value,_UINT8 *ebuffp);
void A_EncodeType(_UINT16 , _UINT8 , _UINT8 *);
void A_EncodeLength(_UINT16 ,_UINT8 *);
void A_EncodeObjectId(_UINT16 , _UINT8 , OBJ_ID_T * , _UINT8 *);
void A_EncodeInt(_UINT16 , _UINT8 , _INT32 ,_UINT8 *);
void A_EncodeUnsignedInt(_UINT16 ,_UINT8 , _UINT32 , _UINT8 *);
void A_EncodeOctetString(_UINT16 ,_UINT8 ,_UINT8 * , _UINT16 ,_UINT8 *);
void A_EncodeUnsignedInt64(_UINT16 ,_UINT8 , UINT64_T * , _UINT8 *);
_UINT16 A_SizeOfUnsignedInt64(UINT64_T *i);
_UINT16 A_DecodeTypeValue(LCL_FILE * , _INT16 *);
_UINT16 A_DecodeLength(LCL_FILE * , _INT16 *);
_INT32 A_DecodeIntegerData(LCL_FILE * , _UINT16 , _INT16 *);
_INT32 A_DecodeIntegerWTC(LCL_FILE * , _INT16 * , _UINT16 , _UINT8);
void A_DecodeObjectIdWTC(LCL_FILE * , OBJ_ID_T * , _INT16 * , _UINT16 , _UINT8);
void A_DecodeOctetStringData(LCL_FILE * , _UINT16 , _UINT8 * ,_UINT16 , _INT16 *);
void A_DecodeObjectIdData(LCL_FILE * , _UINT16 , OBJ_ID_T * , _INT16 *);
void A_DecodeInteger64Data(LCL_FILE * , _UINT16 , UINT64_T * , _INT16 *);
void A_DecodeOctetStringWTC(LCL_FILE * , _UINT8 * ,_UINT16 ,_INT16 * , _UINT16 , _UINT8);
void format_snmp_trap_oid(VB_T *vbp);
void format_sysuptime_oid(VB_T *vbp);
_INT16 Decode_Pkt_To_Vb(LCL_FILE *stream, VB_T *vbp, SNMP_PKT_T *rp);
_INT16 Decode_Pkt_To_VbList(LCL_FILE *stream, SNMP_PKT_T *rp);
_INT16 SNMP_Decode_PDU(SNMP_PKT_T *rp, LCL_FILE *in_stream);
_INT16 SNMP_Decode_V1V2_Packet(SNMP_PKT_T *rp,LCL_FILE *in_stream,_UINT16 asn1leng); \
void SNMP_Encode_Var_Bind_List(SNMP_PKT_T *rp,_UINT8 *ebuffp);
void SNMP_Encode_Trap_Pdu(SNMP_PKT_T *rp,_UINT8 *ebuffp);
void SNMP_Encode_Normal_Pdu(SNMP_PKT_T *rp,_UINT8 *ebuffp);
void SNMP_Encode_Common(_UINT8 *ebuffp,_UINT16 overall_length, _INT16 snmp_version, _UINT8 *community);

_INT16 process_packet_oid(_UINT8  pdu_type,VB_T *vbp);
_INT16 Count_Var_Binds(LCL_FILE *stream, _UINT16 length);
void trapSvrMac_learn_callback(void);
SNMP_PKT_T *create_public_trap(SNMP_PKT_T *rp,int id);
SNMP_PKT_T *create_public_trap_v2(SNMP_PKT_T *rp,int id);
void send_public_trap(int id);
void send_public_trap_v2(int id);
_INT32 snmp_eventlistener(_INT8 cbhandle, _UINT8 event, _UINT32 remip,
                          _UINT16 remport,_UINT16 bufindex,_UINT16 dlen);

int snmpDebug(const char *format, ...);

int set_community(int idx,char *community);
int get_community(int idx,char *community);
_UINT8 udp_send_trap(SNMP_PKT_T *,_UINT16);
_UINT8 is_trap_enable(void);
extern _UINT8 gSnmpDebug;

#if 1
#define SNMP_DEBUG if(gSnmpDebug) printf
#else
#define SNMP_DEBUG if(0) printf
#endif

_UINT32 Uint32Get(VB_T *);
_INT32  Int32Get(VB_T *);
_UINT8   *octetGet(VB_T *);
_UINT32 *oidGet(VB_T *);
void Uint32Set(VB_T *,_UINT32);
void GaugeSet(VB_T *,_UINT32);
void CounterSet(VB_T *,_UINT32);
void Counter64Set(VB_T *,_UINT32 ,_UINT32);
void Int32Set(VB_T *,_INT32);
void TimetickSet(VB_T *,_UINT32);
void oidSet(VB_T *,_UINT32 *pOid,_UINT16);
void octetSet(VB_T *,_UINT8 *pValue,_INT16);
void IpAddrSet(VB_T *vbp,_UINT32 addr);
_UINT32 IpAddrGet(VB_T *vbp);
_INT16 oidcmp(_UINT16 n1, _UINT32 *idp1,_UINT16 n2,_UINT32 *idp2,_INT16 *matchLen);
void learn_trap_server_mac(void);
void oid_print(OBJ_ID_T *pOid);
void oidcpy(OBJ_ID_T *pDst,OBJ_ID_T *pSrc);
void snmp_set_sysName(char *tmp);
void snmp_set_sysdescr(char *tmp);
void snmp_set_def_dev_name(char *tmp);
char *snmp_get_sysdescr(void);
#endif

